$cargoBinPath = Join-Path $env:USERPROFILE '.cargo\bin'
Write-Host "Cargo path: $cargoBinPath"

# Check if Cargo path is already in PATH
if (-not $env:PATH.Contains($cargoBinPath)) {
    # Add to user environment variable
    [Environment]::SetEnvironmentVariable('PATH', "$env:PATH;$cargoBinPath", 'User')
    Write-Host "Added Cargo path to user environment variable"

    # Update current session's PATH
    $env:PATH += ";$cargoBinPath"
    Write-Host "Updated current session PATH"
} else {
    Write-Host "Cargo path is already in PATH"
}

# Verify cargo is available
cargo --version